package com.lbb.socket;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
	
	
	public static void main(String[] args) {
		
		
		ThreadLocal<String> usercash = new ThreadLocal<String>();
		
		
		usercash.set("3");
		String   session = usercash.get();
		
		if (session != null){
			
		}
		
		
		Socket client = null;
		OutputStream  os = null;
		InputStream in = null;
		try {
			client  = new Socket("127.0.0.1", 8888);
			
			os =  client.getOutputStream();
			os.write("hello".getBytes());
			
			client.shutdownOutput();
//			
			byte [] b = new byte[1024];
			in = client.getInputStream();
			in.read(b);
			
			System.out.println("response:"+new String(b));
			
			client.shutdownInput();
		} catch (IOException e) {
			e.printStackTrace();
		}
		finally{
			
			try {
				client.close();
				os.close();
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		
		
	}

}
